package entity.device.dto;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import entity.device.EquipmentArchives;

public class EquipmentQueryWrapper {
    public QueryWrapper<EquipmentArchives> queryWrapper(EquipmentArchives equipmentArchives){
        QueryWrapper<EquipmentArchives> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("delete_flag",0);
        if (equipmentArchives.getEquipmentNumber() != null){
            String equipmentNumber = equipmentArchives.getEquipmentNumber();
            queryWrapper.like("equipment_number",equipmentNumber).or().like("devicename",equipmentNumber);
        }
        if (equipmentArchives.getArchivesId()!=null){
            Integer deviceType = equipmentArchives.getDeviceType();
            queryWrapper.eq("device_type",deviceType);
        }
        if (equipmentArchives.getPlaceForStorage()!=null){
            Integer placeForStorage = equipmentArchives.getPlaceForStorage();
            queryWrapper.eq("place_for_storage",placeForStorage);
        }
        if (equipmentArchives.getCurrentStatus()!=null){
            Integer currentStatus = equipmentArchives.getCurrentStatus();
            queryWrapper.eq("current_status",currentStatus);
        }
        return queryWrapper;
    }
}
